<?php

namespace app\admin\logic;

use app\common\model\CommonMenu;
use app\common\utils\Helper;
use support\Cache;
use think\facade\Db;

/**
 * 经销商逻辑层
 */
class CommonMenuLogic extends BaseLogic
{
    /**
     * 构造函数
     */
    public function __construct()
    {
        $this->model = new CommonMenu();
    }

    /**
     * 数据树形化
     * @param $where
     * @return array
     */
    public function tree($where = [], $extWhere = []): array
    {
        $query = $this->search($where);
        if (!empty($extWhere)) {
            $query->where($extWhere);
        }
        $query->field('*, id as value, title as label, pid as parent_id');
        $query->order('id', 'asc');
        $data = $this->getAll($query);
        return Helper::makeTree($data);
    }

}
